//---------------------------------------------------------------------------

#ifndef motionH
#define motionH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Grids.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
#include <jpeg.hpp>
#include "YbCommDevice.h"
#include <Graphics.hpp>
#include "perfgrap.h"
#include "pies.h"
#include <ExtDlgs.hpp>

#define MOTOR_NUM 			27
#define POSITION_MIN		0
//#define POSITION_MAX 		1023
#define SPEED_MIN 			0
#define SPEED_MAX 			1023

//---------------------------------------------------------------------------
class TFormMotion : public TForm
{
__published:	// IDE-managed Components
        TStringGrid *Motion;
        TMainMenu *MainMenu1;
        TMenuItem *mnuFile;
		TMenuItem *mnuOpenOld;
        TMenuItem *mnuAnother;
        TMenuItem *N1;
        TMenuItem *mnuExit;
        TMenuItem *mnuSetting;
        TMenuItem *mnuComm;
	TOpenDialog *OpenDialogMFile;
	TSaveDialog *SaveDialogMFile;
        TTimer *Timer_play;
        TProgressBar *ProgressBar1;
        TMenuItem *mnuOutput;
	TSaveDialog *SaveDialogMFileOutPut;
        TTimer *Timer_update;
        TOpenDialog *OpenDialogPlus;
        TSaveDialog *SaveDialogPlus;
	TGroupBox *GroupBox4;
	TLabel *Labelx1;
	TLabel *Label35;
	TEdit *Edit_p;
	TEdit *Edit_s;
	TButton *Button_fix;
	TGroupBox *GroupBox5;
	TPageControl *PageControl_Tool;
	TTabSheet *TabSheet1;
	TTabSheet *TabSheet2;
	TGroupBox *GroupBox7;
	TShape *Shape14;
	TLabel *Label50;
	TShape *Shape15;
	TLabel *Label51;
	TShape *Shape16;
	TLabel *Label52;
	TShape *Shape17;
	TLabel *Label53;
	TShape *Shape18;
	TLabel *Label54;
	TShape *Shape19;
	TLabel *Label55;
	TShape *Shape20;
	TLabel *Label56;
	TShape *Shape21;
	TLabel *Label57;
	TShape *Shape22;
	TLabel *Label58;
	TShape *Shape23;
	TLabel *Label59;
	TShape *Shape34;
	TLabel *Label60;
	TShape *Shape35;
	TLabel *Label61;
	TShape *Shape36;
	TLabel *Label62;
	TShape *Shape37;
	TLabel *Label63;
	TShape *Shape38;
	TLabel *Label64;
	TShape *Shape39;
	TShape *Shape40;
	TLabel *Label66;
	TShape *Shape41;
	TLabel *Label67;
	TShape *Shape42;
	TLabel *Label68;
	TShape *Shape43;
	TLabel *Label69;
	TShape *Shape44;
	TLabel *Label70;
	TShape *Shape45;
	TLabel *Label71;
	TShape *Shape46;
	TLabel *Label72;
	TLabel *Label65;
	TEdit *EditP00;
	TButton *Button17;
	TButton *Button18;
	TEdit *EditP04;
	TButton *Button19;
	TButton *Button20;
	TButton *Button21;
	TButton *Button22;
	TEdit *EditP03;
	TEdit *EditP01;
	TButton *Button23;
	TButton *Button24;
	TButton *Button25;
	TButton *Button26;
	TEdit *EditP06;
	TButton *Button27;
	TButton *Button28;
	TEdit *EditP07;
	TEdit *EditP21;
	TButton *Button29;
	TButton *Button30;
	TEdit *EditP05;
	TButton *Button31;
	TButton *Button32;
	TEdit *EditP22;
	TButton *Button33;
	TButton *Button34;
	TEdit *EditP08;
	TButton *Button35;
	TButton *Button36;
	TEdit *EditP02;
	TButton *Button37;
	TButton *Button38;
	TEdit *EditP09;
	TButton *Button39;
	TButton *Button40;
	TEdit *EditP15;
	TButton *Button41;
	TButton *Button42;
	TEdit *EditP10;
	TButton *Button43;
	TButton *Button44;
	TButton *Button46;
	TEdit *EditP11;
	TButton *Button47;
	TButton *Button48;
	TEdit *EditP17;
	TEdit *EditP16;
	TButton *Button49;
	TButton *Button50;
	TButton *Button51;
	TButton *Button52;
	TEdit *EditP12;
	TButton *Button53;
	TButton *Button54;
	TEdit *EditP18;
	TEdit *EditP14;
	TButton *Button55;
	TButton *Button56;
	TButton *Button57;
	TButton *Button58;
	TEdit *EditP13;
	TButton *Button59;
	TButton *Button60;
	TEdit *EditP19;
	TEdit *EditP20;
	TButton *Button61;
	TButton *Button62;
	TButton *ButtonOpenPlus;
	TButton *ButtonSavePlus;
	TButton *ButtonPlusCancel;
	TButton *Button45;
	TTabSheet *TabSheet4;
	TTabSheet *TabSheet5;
	TGroupBox *RemoteControlSet;
	TButton *Button_WALK_FFF;
	TButton *Button_SHIFT_LLL;
	TButton *Button_SHIFT_RRR;
	TButton *Button_WALK_BBB;
	TButton *Button_THROW;
	TButton *Button_PICKUP;
	TButton *Button_UPSTAIR;
	TButton *Button_DOWNSTAIR;
	TButton *Button_GETUP_F;
	TButton *Button_WALK_FF;
	TButton *Button_WALK_BB;
	TButton *Button_SHIFT_RR;
	TButton *Button_SHIFT_LL;
	TButton *Button_STANDING;
	TTabSheet *Advanced;
	TTabSheet *TabSheet6;
	TGroupBox *GroupBoxACC;
	TLabel *Label78;
	TLabel *Label_ACC_x;
	TLabel *Label79;
	TLabel *Label_ACC_y;
	TLabel *Label81;
	TLabel *Label_ACC_z;
	TGroupBox *GroupBoxACC_wave;
	TPerformanceGraph *PerformanceGraphACC;
	TGroupBox *GroupBoxGyro;
	TLabel *Label8;
	TLabel *Label_Gyro_x;
	TLabel *Label13;
	TLabel *Label_Gyro_y;
	TLabel *Label15;
	TLabel *Label_Gyro_z;
	TGroupBox *GroupBoxGyro_wave;
	TPerformanceGraph *PerformanceGraphGyro;
	TGroupBox *GroupBoxFroce;
	TLabel *Label9;
	TLabel *Label_ZMP_L;
	TLabel *Label16;
	TLabel *Label_ZMP_R;
	TGroupBox *GroupBoxZMP_Graph;
	TImage *ImageZMP;
	TPerformanceGraph *PerformanceGraphZMP;
	TGroupBox *GroupBoxRobotSIM;
	TGroupBox *GroupBox8;
	TLabel *Label17;
	TComboBox *ComboBox_Robot_Name;
	TStatusBar *StatusBar_down;
	TGroupBox *GroupBox9;
	TImage *ImageYZ;
	TGroupBox *GroupBox10;
	TImage *ImageXZ;
	TTimer *Timer_Sim;
	TGroupBox *GroupBoxRobotSize;
	TLabel *Label18;
	TPageControl *PageControl_RobotSize;
	TTabSheet *TabSheet3;
	TLabel *Label90;
	TLabel *Label91;
	TEdit *Edit_C1;
	TEdit *Edit_C2;
	TTabSheet *TabSheet7;
	TLabel *Label87;
	TLabel *Label88;
	TLabel *Label22;
	TEdit *Edit_B1;
	TEdit *Edit_B2;
	TEdit *Edit_B3;
	TTabSheet *TabSheet8;
	TLabel *Label20;
	TLabel *Label21;
	TEdit *Edit_H1;
	TEdit *Edit_H2;
	TTabSheet *TabSheet9;
	TLabel *Label23;
	TLabel *Label24;
	TLabel *Label92;
	TLabel *Label93;
	TEdit *Edit_L1;
	TEdit *Edit_L2;
	TEdit *Edit_L3;
	TEdit *Edit_L4;
	TTabSheet *TabSheet10;
	TLabel *Label19;
	TLabel *Label82;
	TLabel *Label86;
	TEdit *Edit_S_WI;
	TEdit *Edit_S_WO;
	TEdit *Edit_S_LF;
	TGroupBox *GroupBox2;
	TImage *ImageXY;
	TLabel *Label10;
	TComboBox *ComboBoxMotionName;
	TGroupBox *GroupBox6;
	TLabel *Label48;
	TLabel *Label_Send;
	TLabel *Label49;
	TLabel *Label_Receive;
	TGroupBox *GroupBox11;
	TLabel *Label1;
	TEdit *Edit_replay;
	TLabel *Label5;
	TEdit *Edit_delay;
	TGroupBox *GroupBoxMotorWave;
	TButton *ButtonOpenMWE;
	TButton *Button_insert;
	TButton *Button_del;
	TButton *Button_off;
	TGroupBox *GroupBox1;
	TLabel *Label2;
	TLabel *Label_re_A;
	TLabel *Label_re_B;
	TButton *Button_re_A;
	TButton *Button_re_B;
	TEdit *Edit_re_num;
	TButton *Button_re_can;
	TGroupBox *GroupBox3;
	TLabel *Label33;
	TLabel *Label34;
	TLabel *Label12;
	TLabel *Label11;
	TLabel *Label_Time;
	TLabel *Label_total;
	TLabel *LabelRow;
	TLabel *LabelCol;
	TLabel *Label_P;
	TLabel *Label76;
	TUpDown *UpDown1;
	TButton *Button_edit;
	TButton *Button_play;
	TButton *Button_mirror_LR;
	TButton *Button_re;
	TGroupBox *GroupBoxBattery;
	TLabel *V1;
	TLabel *V2;
	TLabel *V3;
	TStaticText *StaticText24;
	TStaticText *StaticText25;
	TStaticText *StaticText26;
	TGroupBox *GroupBox12;
	TLabel *Label80;
	TLabel *Label94;
	TLabel *Label95;
	TLabel *Label96;
	TLabel *Label97;
	TLabel *Label98;
	TLabel *Label99;
	TLabel *Label100;
	TEdit *Edit_Leg_L_X;
	TEdit *Edit_Leg_L_Y;
	TEdit *Edit_Leg_L_Z;
	TEdit *Edit_Leg_R_X;
	TEdit *Edit_Leg_R_Y;
	TEdit *Edit_Leg_R_Z;
	TGroupBox *GroupBox13;
	TButton *ButtonSim;
	TButton *ButtonSimPause;
	TButton *ButtonSimStop;
	TLabel *Label101;
	TEdit *Edit_C3;
	TLabel *Label102;
	TEdit *Edit_B4;
	TLabel *Label103;
	TEdit *Edit_B5;
	TLabel *Label104;
	TEdit *Edit_S_LR;
	TLabel *Label105;
	TEdit *Edit_C4;
	TLabel *Label106;
	TEdit *Edit_H3;
	TLabel *Label107;
	TEdit *Edit_H4;
	TPageControl *PageControl_SimInfo;
	TTabSheet *TabSheet11;
	TTabSheet *TabSheet12;
	TTabSheet *TabSheet13;
	TGroupBox *GroupBoxSimInfo;
	TLabel *Label83;
	TLabel *Label_SimScale;
	TLabel *Label84;
	TLabel *Label_SimFPS;
	TLabel *Label85;
	TLabel *Label_SimSpeed;
	TLabel *Label89;
	TLabel *Label_SimCurrentPose;
	TTrackBar *TrackBarSimScale;
	TTrackBar *TrackBarSimFPS;
	TTrackBar *TrackBarSimSpeed;
	TTabSheet *TabSheet14;
	TPerformanceGraph *PerformanceGraph_dX;
	TPerformanceGraph *PerformanceGraph_dY;
	TPerformanceGraph *PerformanceGraph_dZ;
	TTabSheet *TabSheet15;
	TGroupBox *GroupBox15;
	TLabel *Label108;
	TLabel *Label112;
	TLabel *Label113;
	TTrackBar *TrackBar_RdX;
	TTrackBar *TrackBar_RdY;
	TTrackBar *TrackBar_RdZ;
	TLabel *Label114;
	TLabel *Label115;
	TLabel *Label116;
	TLabel *Label117;
	TLabel *Label118;
	TLabel *Label119;
	TLabel *Label120;
	TLabel *Label121;
	TLabel *Label_L_Theta1;
	TLabel *Label_L_Theta2;
	TLabel *Label_L_Theta3;
	TLabel *Label_R_Theta1;
	TLabel *Label_R_Theta2;
	TLabel *Label_R_Theta3;
	TLabel *Label128;
	TEdit *Edit_COM_H;
	TTabSheet *TabSheet16;
	TGroupBox *GroupBox14;
	TLabel *Label109;
	TLabel *Label110;
	TLabel *Label111;
	TTrackBar *TrackBar_LdX;
	TTrackBar *TrackBar_LdY;
	TTrackBar *TrackBar_LdZ;
	TLabel *Label122;
	TLabel *Label_R_dXYZ;
	TLabel *Label_L_dXYZ;
	TLabel *Label124;
	TButton *Button_LoadPose;
	TImage *Image1;
	TMenuItem *Functions1;
	TMenuItem *ScaleModification2;
	TMenuItem *MotionCorrection1;
	TTabSheet *TabSheet17;
	TMemo *Memo_CommSend;
	TMemo *Memo_Motor_data;
	TGroupBox *GroupBox17;
	TButton *Button_KICK_L;
	TButton *Button_KICK_LL;
	TButton *Button_KICK_LLL;
	TGroupBox *GroupBox19;
	TButton *Button_KICK_RRR;
	TButton *Button_KICK_RR;
	TButton *ButtonKICK_R;
	TGroupBox *GroupBox20;
	TGroupBox *GroupBox21;
	TGroupBox *GroupBox23;
	TButton *Button_TURNBALL_LLL;
	TButton *Button_TURNBALL_RRR;
	TButton *Button_TURN_RRR;
	TButton *Button_TURNBALL_LL;
	TButton *Button_TURNBALL_L;
	TButton *Button_TURNBALL_RR;
	TButton *Button_TURNBALL_R;
	TButton *Button_TURN_RR;
	TButton *Button_TURN_R;
	TGroupBox *GroupBox25;
	TButton *Button_DEFEND_LLL;
	TButton *Button_DEFEND_RRR;
	TButton *Button_DEFEND_LL;
	TButton *Button_DEFEND_RR;
	TButton *Button_DEFEND_L;
	TButton *Button_DEFEND_R;
	TButton *Button_WALK_F;
	TButton *Button_SHIFT_L;
	TButton *Button_SHIFT_R;
	TButton *Button_WALK_B;
	TShape *Shape1;
	TShape *Shape_Heading_Dir;
	TGroupBox *GroupBox24;
	TButton *Button_TURN_LLL;
	TButton *Button_TURN_LL;
	TButton *Button_TURN_L;
	TShape *Shape3;
	TShape *Shape4;
	TButton *Button_SQUAT;
	TGroupBox *GroupBox18;
	TButton *ButtonWaistLeft;
	TButton *ButtonWaistCenter;
	TButton *ButtonWaistRight;
	TGroupBox *GroupBox22;
	TScrollBar *ScrollBar_Motor1;
	TScrollBar *ScrollBar_Motor0;
	TLabel *Label77;
	TLabel *Label123;
	TButton *Button_STANDUP;
	TCheckBox *CheckBoxPolling;
	TCheckBox *CheckBox_MtnC;
	TGroupBox *GroupBox26;
	TLabel *Label74;
	TLabel *LabelDone;
	TLabel *LabelACK;
	TLabel *LabelRMTcom;
	TLabel *Label75;
	TLabel *Label73;
	TPageControl *PageControl1;
	TTabSheet *TabSheet18;
	TLabel *Label3;
	TEdit *Edit_Command;
	TEdit *Edit_Command_Head;
	TLabel *Label125;
	TTabSheet *TabSheet19;
	TTabSheet *TabSheet20;
	TLabel *Label45;
	TEdit *Edit_PICKUP;
	TEdit *Edit_THROW;
	TLabel *Label46;
	TLabel *Label31;
	TEdit *Edit_UPSTAIR;
	TEdit *Edit_DOWNSTAIR;
	TLabel *Label32;
	TLabel *Label47;
	TEdit *Edit_STANDING;
	TEdit *Edit_GETUP_B;
	TLabel *Label126;
	TLabel *Label40;
	TEdit *Edit_SQUAT;
	TEdit *Edit_STANDUP;
	TLabel *Label41;
	TLabel *Label37;
	TLabel *Label43;
	TLabel *Label44;
	TEdit *Edit_KICK_R;
	TEdit *Edit_KICK_L;
	TEdit *Edit_KICK_RR;
	TEdit *Edit_KICK_LL;
	TEdit *Edit_KICK_RRR;
	TEdit *Edit_WALK_FFF;
	TEdit *Edit_WALK_BBB;
	TEdit *Edit_WALK_FF;
	TEdit *Edit_WALK_BB;
	TEdit *Edit_WALK_F;
	TEdit *Edit_WALK_B;
	TLabel *Label4;
	TLabel *Label29;
	TEdit *Edit_SHIFT_RRR;
	TEdit *Edit_SHIFT_LLL;
	TEdit *Edit_SHIFT_RR;
	TEdit *Edit_SHIFT_LL;
	TEdit *Edit_SHIFT_R;
	TEdit *Edit_SHIFT_L;
	TLabel *Label26;
	TLabel *Label25;
	TEdit *Edit_TURN_RRR;
	TEdit *Edit_TURN_LLL;
	TEdit *Edit_TURN_RR;
	TEdit *Edit_TURN_LL;
	TEdit *Edit_TURN_R;
	TEdit *Edit_TURN_L;
	TLabel *Label27;
	TLabel *Label30;
	TEdit *Edit_TURNBALL_RRR;
	TEdit *Edit_TURNBALL_LLL;
	TEdit *Edit_TURNBALL_RR;
	TEdit *Edit_TURNBALL_LL;
	TEdit *Edit_TURNBALL_R;
	TEdit *Edit_TURNBALL_L;
	TLabel *Label28;
	TLabel *Label36;
	TEdit *Edit_DEFEND_RRR;
	TEdit *Edit_DEFEND_LLL;
	TEdit *Edit_DEFEND_RR;
	TEdit *Edit_DEFEND_LL;
	TEdit *Edit_DEFEND_R;
	TEdit *Edit_DEFEND_L;
	TLabel *Label38;
	TLabel *Label39;
	TEdit *Edit_KICK_LLL;
	TLabel *Label42;
	TEdit *Edit_STOP;
	TEdit *Edit_STEP;
	TLabel *Label127;
	TLabel *Label129;
	TLabel *Label130;
	TEdit *Edit_WALK;
	TEdit *Edit_SHIFT;
	TEdit *Edit_TURN;
	TEdit *Edit_TURNBALL;
	TLabel *Label131;
	TLabel *Label132;
	TButton *Button_STEP;
	TButton *ButtonSTOP;
	TButton *Button2;
	TEdit *Edit_Motor0;
	TEdit *Edit_Motor1;
	TLabel *Label133;
	TLabel *Label_ACC_x_max;
	TLabel *Label135;
	TLabel *Label_ACC_y_max;
	TLabel *Label137;
	TLabel *Label_ACC_z_max;
	TLabel *Label139;
	TLabel *Label_Gyro_x_max;
	TLabel *Label141;
	TLabel *Label_Gyro_y_max;
	TLabel *Label143;
	TLabel *Label_Gyro_z_max;
	TLabel *Label134;
	TLabel *Label_ACC_x_min;
	TLabel *Label138;
	TLabel *Label_ACC_y_min;
	TLabel *Label142;
	TLabel *Label_ACC_z_min;
	TLabel *Label145;
	TLabel *Label_Gyro_x_min;
	TLabel *Label147;
	TLabel *Label_Gyro_y_min;
	TLabel *Label149;
	TLabel *Label_Gyro_z_min;
	TButton *Button_REC;
	TLabel *Label6;
	TComboBox *ComboBox_Wave_axis;
	TLabel *Label7;
	TTrackBar *TrackBar_Wave_Scale;
	TLabel *Label_Wave_Scale;
	TButton *Button_Reset_Sensor_MinMax;
	TShape *Shape2;
	TPie *Pie_Gyro_x;
	TShape *Shape5;
	TPie *Pie_Gyro_y;
	TShape *Shape6;
	TPie *Pie_Gyro_z;
	TLabel *Label136;
	TLabel *Label144;
	TShape *Shape7;
	TShape *Shape8;
	TShape *Shape9;
	TLabel *Label140;
	TGroupBox *GroupBox16;
	TShape *Shape_Acc_x;
	TShape *Shape_Acc_y;
	TShape *Shape_Acc_z;
	TShape *Shape10;
	TShape *Shape11;
	TShape *Shape12;
	TShape *Shape13;
	TShape *Shape24;
	TShape *Shape25;
	TLabel *Label151;
	TLabel *Label_Force_R1;
	TLabel *Label153;
	TLabel *Label_Force_R2;
	TLabel *Label155;
	TLabel *Label_Force_R3;
	TLabel *Label157;
	TLabel *Label_Force_R4;
	TLabel *Label159;
	TLabel *Label160;
	TLabel *Label161;
	TLabel *Label162;
	TLabel *Label_Force_L1;
	TLabel *Label_Force_L2;
	TLabel *Label_Force_L3;
	TLabel *Label_Force_L4;
	TTabSheet *TabSheet21;
	TLabel *Label152;
	TLabel *Label_Total_G;
	TLabel *Label146;
	TLabel *Label148;
	TLabel *Label150;
	TLabel *Label154;
	TLabel *Label156;
	TLabel *Label158;
	TSaveDialog *SaveDialog_SensorRecord;
	TButton *Button_GETUP_B;
	TLabel *Label163;
	TEdit *Edit_GETUP_F;
	TTabSheet *TabSheet22;
	TButton *Button_HEAD_STOP;
	TLabel *Label164;
	TEdit *Edit_Command_Head_Mode;
	TButton *Button_HEAD_GO_SLOW;
	TButton *Button_HEAD_GO_MIDDLE;
	TButton *Button_HEAD_GO_FAST;
	TButton *Button_HEAD_SEARCH_UPPER;
	TButton *Button_HEAD_SEARCH_CENTER;
	TButton *Button_HEAD_SEARCH_LOWER;
	TButton *Button_HEAD_SEARCH_UPPER_CENTER;
	TButton *Button_HEAD_SEARCH_HALF_R;
	TButton *Button_HEAD_SEARCH_HALF_L;
	TButton *Button_HEAD_SEARCH_RADIATION_R;
	TButton *Button_HEAD_SEARCH_RADIATION_L;
	TEdit *Edit_HEAD_STOP;
	TEdit *Edit_HEAD_GO_SLOW;
	TEdit *Edit_HEAD_GO_MIDDLE;
	TEdit *Edit_HEAD_GO_FAST;
	TEdit *Edit_HEAD_SEARCH_UPPER;
	TEdit *Edit_HEAD_SEARCH_CENTER;
	TEdit *Edit_HEAD_SEARCH_LOWER;
	TEdit *Edit_HEAD_SEARCH_UPPER_CENTER;
	TEdit *Edit_HEAD_SEARCH_HALF_R;
	TEdit *Edit_HEAD_SEARCH_HALF_L;
	TEdit *Edit_HEAD_SEARCH_RADIATION_R;
	TEdit *Edit_HEAD_SEARCH_RADIATION_L;
	TLabel *Label165;
	TLabel *Label_Heading_Direction;
	TPie *Pie_Heading_Dir;
	TTrackBar *TrackBar_Heading_Distance;
	TLabel *Label166;
	TLabel *Label_Heading_Distance;
	TLabel *Label14;
	TEdit *Edit_SpeedFactor;
	TCheckBox *CheckBox_GenerateABOnly;
	TButton *Button_Cancel_play;
	TButton *Button_add;
	TButton *Button_mirror_FR;
	TStringGrid *Motion_temp;
	TLabel *Label167;
	TEdit *Edit_RaiseArm;
	TButton *Button_RaiseArm;
	TMenuItem *PGRL_Stair_Climbing;
	TButton *Button_START_REC;
	TButton *Button_END_REC;
	TButton *Button1;
	TSavePictureDialog *SavePictureDialog_3View;
	TMenuItem *FPGLforWalking1;
	TButton *ButtonFIRA_WALK_F;
	TButton *ButtonFIRA_WALK_B;
	TCheckBox *CheckBoxFIRA_WALK;
	TEdit *EditFixSwing;
	TLabel *Label168;
	TEdit *EditFixPush;
	TLabel *Label169;
	TEdit *EditFixLift;
	TLabel *Label170;
	TEdit *EditFixLean;
	TLabel *Label171;
	TYbCommDevice *VComm;
	TEdit *Edit_saveREC;
	TLabel *Label172;
	TShape *Shape26;
	TLabel *Label173;
	TEdit *EditP23;
	TButton *Button3;
	TButton *Button4;
	TLabel *Label_ThrowDis;
	TEdit *Edit_ThrowDis;
	TButton *Button_ClearMemoRx;
	TButton *Button_ClearMemoTx;
	TRadioGroup *RadioGroup_RxSelection;
	TEdit *Edit_ZigbeeKeyIn;
	TLabel *Label174;
	TCheckBox *CheckBox_KeyInCheck;
	TLabel *Label175;
	TEdit *Edit_FreeKeyIn;
	TCheckBox *CheckBox_send_rd;
	TGroupBox *GroupBox_Lift;
	TButton *Button_LIFT_L2M;
	TEdit *Edit_LIFT_L2M;
	TButton *Button_LIFT_WALKM;
	TEdit *Edit_LIFT_WALKM;
	TButton *Button_LIFT_M2H;
	TEdit *Edit_LIFT_M2H;
	TButton *Button_LIFT_WALKH;
	TEdit *Edit_LIFT_WALKH;
	TMenuItem *mnuMotionTable;
	TSaveDialog *SaveDialogMTableOutput;
	TCheckBox *CheckBox_ConnectSim;
	TButton *Button_ZigbeeGetReadData;
	TPageControl *PageControl_GaitGeneration;
	TTabSheet *TabSheet23;
	TGroupBox *GroupBox27;
	TGroupBox *GroupBox28;
	TLabel *Label176;
	TLabel *Label177;
	TLabel *Label178;
	TLabel *Label179;
	TEdit *Edit_RightX;
	TEdit *Edit_RightY;
	TEdit *Edit_RightZ;
	TEdit *Edit_RightYaw;
	TButton *Button_InvK_SetRight;
	TGroupBox *GroupBox29;
	TLabel *Label180;
	TLabel *Label181;
	TLabel *Label182;
	TLabel *Label183;
	TEdit *Edit_LeftX;
	TEdit *Edit_LeftY;
	TEdit *Edit_LeftZ;
	TEdit *Edit_LeftYaw;
	TButton *Button_InvK_SetLeft;
	TButton *Button_InvK_SetBoth;
	TGroupBox *GroupBox30;
	TGroupBox *GroupBox31;
	TLabel *Label184;
	TLabel *Label185;
	TLabel *Label186;
	TLabel *Label187;
	TLabel *Label188;
	TLabel *Label189;
	TLabel *Label190;
	TLabel *Label191;
	TEdit *Edit_JointSetting_RHY;
	TComboBox *ComboBox_JointSetting_RHY;
	TEdit *Edit_JointSetting_RHR;
	TComboBox *ComboBox_JointSetting_RHR;
	TEdit *Edit_JointSetting_RHP;
	TComboBox *ComboBox_JointSetting_RHP;
	TEdit *Edit_JointSetting_RKP;
	TComboBox *ComboBox_JointSetting_RKP;
	TEdit *Edit_JointSetting_RAR;
	TComboBox *ComboBox_JointSetting_RAR;
	TEdit *Edit_JointSetting_RAP;
	TComboBox *ComboBox_JointSetting_RAP;
	TGroupBox *GroupBox32;
	TLabel *Label192;
	TLabel *Label193;
	TLabel *Label194;
	TLabel *Label195;
	TLabel *Label196;
	TLabel *Label197;
	TLabel *Label198;
	TLabel *Label199;
	TEdit *Edit_JointSetting_LHY;
	TComboBox *ComboBox_JointSetting_LHY;
	TEdit *Edit_JointSetting_LHR;
	TComboBox *ComboBox_JointSetting_LHR;
	TEdit *Edit_JointSetting_LHP;
	TComboBox *ComboBox_JointSetting_LHP;
	TEdit *Edit_JointSetting_LKP;
	TComboBox *ComboBox_JointSetting_LKP;
	TEdit *Edit_JointSetting_LAR;
	TComboBox *ComboBox_JointSetting_LAR;
	TEdit *Edit_JointSetting_LAP;
	TComboBox *ComboBox_JointSetting_LAP;
	TButton *Button_JointSet;
	TTabSheet *TabSheet24;
	TRadioGroup *RadioGroup_VelocityMode;
	TGroupBox *GroupBox33;
	TLabel *Label200;
	TEdit *Edit_Tratio;
	TButton *Button_GenerateKinematics;
	TTabSheet *TabSheet25;
	TGroupBox *GroupBox34;
	TGroupBox *GroupBox35;
	TLabel *Label201;
	TEdit *Edit_Rx_A;
	TLabel *Label202;
	TEdit *Edit_Rx_T;
	TLabel *Label203;
	TEdit *Edit_Rx_Phi;
	TGroupBox *GroupBox36;
	TLabel *Label204;
	TLabel *Label205;
	TLabel *Label206;
	TEdit *Edit_Ry_A;
	TEdit *Edit_Ry_T;
	TEdit *Edit_Ry_Phi;
	TGroupBox *GroupBox37;
	TLabel *Label207;
	TLabel *Label208;
	TLabel *Label209;
	TEdit *Edit_Rz_A;
	TEdit *Edit_Rz_T;
	TEdit *Edit_Rz_Phi;
	TGroupBox *GroupBox38;
	TGroupBox *GroupBox39;
	TLabel *Label210;
	TLabel *Label211;
	TLabel *Label212;
	TEdit *Edit_Lx_A;
	TEdit *Edit_Lx_T;
	TEdit *Edit_Lx_Phi;
	TGroupBox *GroupBox40;
	TLabel *Label213;
	TLabel *Label214;
	TLabel *Label215;
	TEdit *Edit_Ly_A;
	TEdit *Edit_Ly_T;
	TEdit *Edit_Ly_Phi;
	TGroupBox *GroupBox41;
	TLabel *Label216;
	TLabel *Label217;
	TLabel *Label218;
	TEdit *Edit_Lz_A;
	TEdit *Edit_Lz_T;
	TEdit *Edit_Lz_Phi;
	TButton *Button_SetInvKWave;
	TEdit *Edit_InvK_T;
	TLabel *Label219;
	TGroupBox *GroupBox42;
	TLabel *Label220;
	TLabel *Label221;
	TLabel *Label222;
	TLabel *Label_Rx;
	TLabel *Label_Ry;
	TLabel *Label_Rz;
	TLabel *Label_Lx;
	TLabel *Label227;
	TLabel *Label228;
	TLabel *Label_Ly;
	TLabel *Label230;
	TLabel *Label_Lz;
	TButton *Button_CalculateKinematics;
	TCheckBox *CheckBox_ConnectMotionController;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall MotionSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect);
        void __fastcall menuExitClick(TObject *Sender);
        void __fastcall menuOpenMFileClick(TObject *Sender);
        void __fastcall Button_editClick(TObject *Sender);
        void __fastcall Button_reClick(TObject *Sender);
        void __fastcall MotionKeyPress(TObject *Sender, char &Key);
        void __fastcall menuSaveMFileClick(TObject *Sender);
		//void __fastcall Comm1ReceiveData(TObject *Sender);
        void __fastcall Button_playClick(TObject *Sender);
        void __fastcall MotionDblClick(TObject *Sender);
        void __fastcall Button_addClick(TObject *Sender);
        void __fastcall MotionMouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
        void __fastcall Timer_playTimer(TObject *Sender);
        void __fastcall menuOutputClick(TObject *Sender);
        void __fastcall Edit_pKeyPress(TObject *Sender, char &Key);
        void __fastcall Edit_sKeyPress(TObject *Sender, char &Key);
        void __fastcall mnuCommClick(TObject *Sender);
        void __fastcall MotionKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall Button_mirror_LRClick(TObject *Sender);
        void __fastcall Button_fixClick(TObject *Sender);
        void __fastcall Button_insertClick(TObject *Sender);
        void __fastcall Button_delClick(TObject *Sender);
        void __fastcall Button_re_AClick(TObject *Sender);
        void __fastcall Button_re_BClick(TObject *Sender);
        void __fastcall Button_re_canClick(TObject *Sender);
        void __fastcall UpDown1Click(TObject *Sender, TUDBtnType Button);
        void __fastcall Button_offClick(TObject *Sender);
		void __fastcall FormKeyPress(TObject *Sender, char &Key);
		void __fastcall ButtonOpenPlusClick(TObject *Sender);
        void __fastcall ButtonSavePlusClick(TObject *Sender);
        void __fastcall ButtonPlusCancelClick(TObject *Sender);
        void __fastcall EditP00KeyPress(TObject *Sender, char &Key);
        void __fastcall Button00aClick(TObject *Sender);
        void __fastcall Button00bClick(TObject *Sender);
        void __fastcall Button01bClick(TObject *Sender);
        void __fastcall Button01aClick(TObject *Sender);
        void __fastcall Button02aClick(TObject *Sender);
        void __fastcall Button02bClick(TObject *Sender);
        void __fastcall Button03aClick(TObject *Sender);
        void __fastcall Button03nbClick(TObject *Sender);
        void __fastcall Button04aClick(TObject *Sender);
        void __fastcall Button04bClick(TObject *Sender);
        void __fastcall Button05aClick(TObject *Sender);
        void __fastcall Button05bClick(TObject *Sender);
        void __fastcall Button06bClick(TObject *Sender);
        void __fastcall Button06aClick(TObject *Sender);
        void __fastcall Button07aClick(TObject *Sender);
        void __fastcall Button07bClick(TObject *Sender);
        void __fastcall Button22aClick(TObject *Sender);
        void __fastcall Button22bClick(TObject *Sender);
        void __fastcall Button21aClick(TObject *Sender);
        void __fastcall Button21bClick(TObject *Sender);
        void __fastcall Button08aClick(TObject *Sender);
        void __fastcall Button08bClick(TObject *Sender);
        void __fastcall Button09aClick(TObject *Sender);
        void __fastcall Button09bClick(TObject *Sender);
        void __fastcall Button15aClick(TObject *Sender);
        void __fastcall Button15bClick(TObject *Sender);
        void __fastcall Button11aClick(TObject *Sender);
        void __fastcall Button11bClick(TObject *Sender);
        void __fastcall Button10bClick(TObject *Sender);
        void __fastcall Button10aClick(TObject *Sender);
        void __fastcall Button12aClick(TObject *Sender);
        void __fastcall Button12bClick(TObject *Sender);
        void __fastcall Button13bClick(TObject *Sender);
        void __fastcall Button13aClick(TObject *Sender);
        void __fastcall Button14aClick(TObject *Sender);
        void __fastcall Button14bClick(TObject *Sender);
        void __fastcall Button17bClick(TObject *Sender);
        void __fastcall Button17aClick(TObject *Sender);
        void __fastcall Button18bClick(TObject *Sender);
        void __fastcall Button18aClick(TObject *Sender);
        void __fastcall Button19aClick(TObject *Sender);
        void __fastcall Button19bClick(TObject *Sender);
        void __fastcall Button20bClick(TObject *Sender);
				void __fastcall Button20aClick(TObject *Sender);
				void __fastcall Button23bClick(TObject *Sender);
				void __fastcall Button23aClick(TObject *Sender);
        void __fastcall Button16aClick(TObject *Sender);
        void __fastcall Button16bClick(TObject *Sender);

	void __fastcall VCommCommNotify(TObject *Sender, int NotifyType);
	void __fastcall PageControl_ToolChange(TObject *Sender);
	void __fastcall ScaleModification1Click(TObject *Sender);
	void __fastcall Motorcorrection1Click(TObject *Sender);
	void __fastcall ButtonOpenMWEClick(TObject *Sender);
	void __fastcall ButtonSimClick(TObject *Sender);
	void __fastcall TrackBarSimScaleChange(TObject *Sender);
	void __fastcall TrackBarSimFPSChange(TObject *Sender);
	void __fastcall TrackBarSimSpeedChange(TObject *Sender);
	void __fastcall Timer_SimTimer(TObject *Sender);
	void __fastcall ButtonSimStopClick(TObject *Sender);
	void __fastcall Edit_SpeedFactorKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall MotionMouseEnter(TObject *Sender);
	void __fastcall MotionMouseLeave(TObject *Sender);
	void __fastcall ButtonSimPauseClick(TObject *Sender);
	void __fastcall Timer_updateTimer(TObject *Sender);
	void __fastcall TrackBar_LdXChange(TObject *Sender);
	void __fastcall TrackBar_LdYChange(TObject *Sender);
	void __fastcall TrackBar_LdZChange(TObject *Sender);
	void __fastcall TrackBar_RdXChange(TObject *Sender);
	void __fastcall TrackBar_RdYChange(TObject *Sender);
	void __fastcall TrackBar_RdZChange(TObject *Sender);
	void __fastcall Button_LoadPoseClick(TObject *Sender);
	void __fastcall Button_WALK_FFFClick(TObject *Sender);
	void __fastcall Button_WALK_FFClick(TObject *Sender);
	void __fastcall Button_WALK_FClick(TObject *Sender);
	void __fastcall Button_WALK_BBBClick(TObject *Sender);
	void __fastcall Button_WALK_BBClick(TObject *Sender);
	void __fastcall Button_WALK_BClick(TObject *Sender);
	void __fastcall Button_SHIFT_LLLClick(TObject *Sender);
	void __fastcall Button_SHIFT_LLClick(TObject *Sender);
	void __fastcall Button_SHIFT_LClick(TObject *Sender);
	void __fastcall Button_SHIFT_RRRClick(TObject *Sender);
	void __fastcall Button_SHIFT_RRClick(TObject *Sender);
	void __fastcall Button_SHIFT_RClick(TObject *Sender);
	void __fastcall Button_TURN_LLLClick(TObject *Sender);
	void __fastcall Button_TURN_LLClick(TObject *Sender);
	void __fastcall Button_TURN_LClick(TObject *Sender);
	void __fastcall Button_TURN_RRRClick(TObject *Sender);
	void __fastcall Button_TURN_RRClick(TObject *Sender);
	void __fastcall Button_TURN_RClick(TObject *Sender);
	void __fastcall Button_TURNBALL_LLLClick(TObject *Sender);
	void __fastcall Button_TURNBALL_LLClick(TObject *Sender);
	void __fastcall Button_TURNBALL_LClick(TObject *Sender);
	void __fastcall Button_TURNBALL_RRRClick(TObject *Sender);
	void __fastcall Button_TURNBALL_RRClick(TObject *Sender);
	void __fastcall Button_TURNBALL_RClick(TObject *Sender);
	void __fastcall Button_KICK_LLLClick(TObject *Sender);
	void __fastcall Button_KICK_LLClick(TObject *Sender);
	void __fastcall Button_KICK_LClick(TObject *Sender);
	void __fastcall Button_KICK_RRRClick(TObject *Sender);
	void __fastcall Button_KICK_RRClick(TObject *Sender);
	void __fastcall ButtonKICK_RClick(TObject *Sender);
	void __fastcall Button_DEFEND_LLLClick(TObject *Sender);
	void __fastcall Button_DEFEND_LLClick(TObject *Sender);
	void __fastcall Button_DEFEND_LClick(TObject *Sender);
	void __fastcall Button_DEFEND_RRRClick(TObject *Sender);
	void __fastcall Button_DEFEND_RRClick(TObject *Sender);
	void __fastcall Button_DEFEND_RClick(TObject *Sender);
	void __fastcall Button_STANDINGClick(TObject *Sender);
	void __fastcall Button_SQUATClick(TObject *Sender);
	void __fastcall Button_THROWClick(TObject *Sender);
	void __fastcall Button_PICKUPClick(TObject *Sender);
	void __fastcall Button_UPSTAIRClick(TObject *Sender);
	void __fastcall Button_DOWNSTAIRClick(TObject *Sender);
	void __fastcall Button_STEPClick(TObject *Sender);
	void __fastcall ButtonSTOPClick(TObject *Sender);
	void __fastcall ScrollBar_Motor1Change(TObject *Sender);
	void __fastcall ScrollBar_Motor0Change(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
	void __fastcall Edit_Motor0KeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_Motor1KeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall TrackBar_Wave_ScaleChange(TObject *Sender);
	void __fastcall Button_Reset_Sensor_MinMaxClick(TObject *Sender);
	void __fastcall Button_RECClick(TObject *Sender);
	void __fastcall Button_GETUP_FClick(TObject *Sender);
	void __fastcall Button_GETUP_BClick(TObject *Sender);
	void __fastcall Button_STANDUPClick(TObject *Sender);
	void __fastcall Button_HEAD_STOPClick(TObject *Sender);
	void __fastcall Button_HEAD_GO_SLOWClick(TObject *Sender);
	void __fastcall Button_HEAD_GO_MIDDLEClick(TObject *Sender);
	void __fastcall Button_HEAD_GO_FASTClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_UPPERClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_CENTERClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_LOWERClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_UPPER_CENTERClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_HALF_RClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_HALF_LClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_RADIATION_RClick(TObject *Sender);
	void __fastcall Button_HEAD_SEARCH_RADIATION_LClick(TObject *Sender);
	void __fastcall Pie_Heading_DirMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
	void __fastcall TrackBar_Heading_DistanceChange(TObject *Sender);
	void __fastcall Button_Cancel_playClick(TObject *Sender);
	void __fastcall Button_mirror_FRClick(TObject *Sender);
	void __fastcall Button_RaiseArmClick(TObject *Sender);
	void __fastcall PGRL_Stair_ClimbingClick(TObject *Sender);
	void __fastcall Button_START_RECClick(TObject *Sender);
	void __fastcall Button_END_RECClick(TObject *Sender);
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall FPGLforWalking1Click(TObject *Sender);
	void __fastcall ButtonFIRA_WALK_BClick(TObject *Sender);
	void __fastcall ButtonFIRA_WALK_FClick(TObject *Sender);
	void __fastcall Button_ClearMemoRxClick(TObject *Sender);
	void __fastcall Button_ClearMemoTxClick(TObject *Sender);
	void __fastcall Edit_ZigbeeKeyInKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_FreeKeyInKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall RadioGroup_RxSelectionClick(TObject *Sender);
	void __fastcall Button_LIFT_L2MClick(TObject *Sender);
	void __fastcall Button_LIFT_WALKMClick(TObject *Sender);
	void __fastcall Button_LIFT_M2HClick(TObject *Sender);
	void __fastcall Button_LIFT_WALKHClick(TObject *Sender);
	void __fastcall mnuMotionTableClick(TObject *Sender);
	void __fastcall CheckBox_ConnectSimClick(TObject *Sender);
	void __fastcall Button_InvK_SetRightClick(TObject *Sender);
	void __fastcall Button_InvK_SetLeftClick(TObject *Sender);
	void __fastcall Button_InvK_SetBothClick(TObject *Sender);
	void __fastcall Button_JointSetClick(TObject *Sender);
	void __fastcall RadioGroup_VelocityModeClick(TObject *Sender);
	void __fastcall Button_ZigbeeGetReadDataClick(TObject *Sender);
	void __fastcall Edit_TratioKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Button_GenerateKinematicsClick(TObject *Sender);
	void __fastcall Button_CalculateKinematicsClick(TObject *Sender);
	void __fastcall Button_SetInvKWaveClick(TObject *Sender);
	void __fastcall CheckBox_ConnectMotionControllerClick(TObject *Sender);

private:	// User declarations
public:		// User declarations
		__fastcall TFormMotion(TComponent* Owner);
		Graphics::TBitmap *OrgBitmapYZ;
		Graphics::TBitmap *OrgBitmapXZ;
		Graphics::TBitmap *OrgBitmapXY;
	bool StringToTX(AnsiString str_TX, unsigned char* TX, int TX_length);
	void Clear_TX(unsigned char* TX, int TX_length);
	void ReadVcomm();
};
//---------------------------------------------------------------------------
extern PACKAGE TFormMotion *FormMotion;
//---------------------------------------------------------------------------
#endif
